﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 飞行棋案例
{
    internal class Player
    {
        public static string[] names = new string[2];
        public int size = 0;
        public int[] playerPosition = new int[2];
        public bool[] playerParse = new bool[2];
        public void MountName()
        {
            EnterName();
        }
        public void EnterName()
        {
            while(true)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine($"请输入玩家{size + 1}的姓名：");
                string name = Console.ReadLine();
                if (name == "")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"玩家{size + 1}的姓名不能为空！");
                    continue;
                }
                if(names.Contains(name))
                {
                    Console.ForegroundColor= ConsoleColor.Red;
                    Console.WriteLine("输入的玩家名重复！");
                    continue;
                }
                names[size++] = name;
                Console.WriteLine($"{name} 录入成功");
                Console.WriteLine();
                if (size == names.Length)
                {
                    break;
                }
            }
            Console.WriteLine();
        }

        public void ShowInformation()
        {
            Console.Clear();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"A表示 玩家{names[0]}");

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine($"B表示 玩家{names[1]}");

        }


    }
}
